<script  setup  lang="ts">
import { ref,reactive } from 'vue'
import type { ComponentSize ,FormInstance} from 'element-plus'
import {Delete,Edit} from '@element-plus/icons-vue'
const currentPage4 = ref(1)

const pageSize4 = ref(5)
const size = ref<ComponentSize>('default')
const background = ref(false)
const disabled = ref(false)
const total=ref(20);
const handleSizeChange = (val:number) => {
  console.log(`${val} items per page`)
}
const handleCurrentChange = (val:number) => {
  console.log(`current page: ${val}`)
}

const formInline = reactive({
  categoryName: '',
  state: '',
})

const onSubmit = () => {
  console.log('submit!')
}
const tableData = [
  {
    title: '标题1',
    categoryName: '民族团结',
    createTime: '2023-01-05',
    state:'已发布'
  }, {
    title: '标题2',
    categoryName: '政治理论',
    createTime: '2023-01-06',
    state:'已发布'
  }, {
    title: '标题3',
    categoryName: '军事战术',
    createTime: '2023-01-07',
    state:'已发布'
  },
]
const resetForm = (formEl: FormInstance | undefined) => {
  formEl.resetFields()
}
</script>
<template>

<el-card >
      <div class="card-header">
        <span>Card name</span>
        <el-button type="primary">Operation</el-button>
      </div>
      <div style="margin-top: 20px;">
        <hr>
      </div>

      <el-form :inline="true" :model="formInline" class="demo-form-inline">
    <el-form-item label="文章分类">
      <el-select v-model="formInline.categoryName"  placeholder="请选择" clearable>
        <el-option label="请选择" value="" />
        <el-option label="军事" value="军事" />
        <el-option label="民族" value="民族" />
      </el-select>
    </el-form-item>
    <el-form-item label="发布状态">
      <el-select  v-model="formInline.state"  placeholder="请选择" clearable>
        <el-option label="请选择" value="" />
        <el-option label="已发布" value="已发布" />
        <el-option label="草稿" value="草稿" />
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">搜索</el-button>
    </el-form-item>
    <el-form-item>
      <el-button type="default" @click="resetForm(formInline)">重置</el-button>
    </el-form-item>
  </el-form>

  <el-table :data="tableData"  height="250" >
    <el-table-column prop="title" label="文章标题" />
    <el-table-column prop="categoryName" label="分类"  />
    <el-table-column prop="createTime" label="发表时间" />
    <el-table-column prop="state" label="状态"  />
    <el-table-column label="操作"  width="180" >    
      <el-button type="primary" :icon="Edit" circle />
      <el-button type="danger"  :icon="Delete" circle />
    </el-table-column>
  </el-table>

    <el-pagination class="el-p"
      v-model:current-page="currentPage4"
      v-model:page-size="pageSize4"
      :page-sizes="[5, 10, 15, 20]"
      :size="size"
      :disabled="disabled"
      :background="background"
      layout="jumper,total, sizes, prev, pager, next"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
</el-card>

 
</template>
<style scoped>
.card-header{
  display: flex;
  justify-content: space-between;
}
.demo-form-inline .el-input {
  --el-input-width: 220px;
}

.demo-form-inline .el-select {
  --el-select-width: 220px;
}

.el-p{
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}


</style>

